package com.ruoyi.web.controller.house;

import com.github.pagehelper.PageHelper;
import com.ruoyi.system.domain.Equipment;
import com.ruoyi.system.domain.dto.EquipmentQueryDto;
import com.ruoyi.system.domain.vo.EquipmentVo;
import com.ruoyi.system.service.IEquipmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/house/equipment")
public class EquipmentController {

    @Autowired
    private IEquipmentService equipmentService;

    @PostMapping("/list")
    public Map getEquipmentList(@RequestBody EquipmentQueryDto dto){
        return equipmentService.getEquipmentList(dto);
    }

    @PostMapping("/add")
    public void add(@RequestBody Equipment equipment){
        equipmentService.save(equipment);
    }
    @PutMapping()
    public void update(@RequestBody Equipment equipment){
        equipmentService.updea(equipment);
    }
    @PutMapping("/changeEquipmentStatus")
    public void changeEquipmentStatus(@RequestBody Equipment equipment) {
        equipmentService.changeEquipmentStatus(equipment);
    }

    @DeleteMapping("/{ids}")
    public void deleteEquipment(@PathVariable("ids") Long [] ids) {
        equipmentService.removeByIds(ids);
    }

    @PostMapping("/equipmentList")
    public List<EquipmentVo> getEquipmentVoList() {
        return equipmentService.getEquipmentVoList();
    }
}
